#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <WinCrypt.h>

class CCrypt
{
// Attributes
public:
	class CCryptError {};
// Operations
public:
	CCrypt();
	virtual ~CCrypt();

// Overrides
public:
	BOOL Decrypt(void* lpBuf, int& nBufLen, const char* szPassword = NULL);
	BOOL Encrypt(void* lpBuf, int& nBufLen, const char* szPassword = NULL);

// Implementation
protected:
	void DestroyCryptSession();
private:
//	hashing the password
	char* m_szOldPassword;
//	CRYPT algorithm
	HCRYPTPROV 	m_hCryptProv;
	HCRYPTKEY	m_hKey;
	HCRYPTKEY	m_hXchgKey;
	HCRYPTHASH	m_hHash;

	PBYTE	m_pbKeyBlob;
	DWORD	m_dwKeyBlobLen;

	PBYTE	m_pbBuffer;
	DWORD	m_dwBlockLen;
	DWORD	m_dwBufferLen;
	DWORD	m_dwCount;
};

/////////////////////////////////////////////////////////////////////////////
